import java.awt.*;
import java.util.Scanner;

public class Demo4 {
    public static void main(String[] args) {
        Object object=new Object();
        Thread t1=new Thread(()->{
                try {
                    synchronized (object) {
                        System.out.println("wait 之前");
                        object.wait();
                    }
                    System.out.println("wait 之后");
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

        });


        Thread t2=new Thread(()->{
            try {
                synchronized (object) {
                    System.out.println("wait 之前");
                    object.wait();
                }
                System.out.println("wait 之后");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        });
        Thread t3=new Thread(()->{
            Scanner sc=new Scanner(System.in);
            System.out.println("请输入任意内容,通知唤醒t1");
            sc.next();
            synchronized (object){
                object.notify();
            }
        });


        t1.start();
        t2.start();
        t3.start();
    }
}
